package org.example.bean.entity.product;

import com.bianmaba.spring.data.jpa.domain.annotations.QueryCacheable;
import com.bianmaba.spring.data.jpa.domain.entity.UuidIdentityEntity;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import java.util.Date;

/**
 * @program: example-web-framework-extends-2x
 * @description:
 * @author: Chenjiabin
 * @create: 2018-04-22 20:29
 **/
@DynamicUpdate(true)
@DynamicInsert(true)
@Entity
//此注解重新定义为是否开启查询缓存
@QueryCacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "Product")
@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"name"})})
public class Product extends UuidIdentityEntity {
    @Column(nullable = false, length = 255)
    private String name;

    @Column(nullable = false, length = 32)
    private String no;

    @Column(nullable = false)
    private String smallImage;

    @Column()
    private Double marketPrice;

    @Column()
    private Double price;

    @Column(columnDefinition = "TEXT")
    private String description;

    @Column(nullable = false)
    private Boolean enabled = true;

    @Column()
    private Integer hits;

    @Column()
    private Integer idx = 0;

    @Column()
    private Date cdt = new Date();

    private String[] test;

    public String[] getTest() {
        return test;
    }

    public void setTest(String[] test) {
        this.test = test;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public String getSmallImage() {
        return smallImage;
    }

    public void setSmallImage(String smallImage) {
        this.smallImage = smallImage;
    }

    public Double getMarketPrice() {
        return marketPrice;
    }

    public void setMarketPrice(Double marketPrice) {
        this.marketPrice = marketPrice;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public Integer getHits() {
        return hits;
    }

    public void setHits(Integer hits) {
        this.hits = hits;
    }


    public Integer getIdx() {
        return idx;
    }

    public void setIdx(Integer idx) {
        this.idx = idx;
    }

    public Date getCdt() {
        return cdt;
    }

    public void setCdt(Date cdt) {
        this.cdt = cdt;
    }
}
